////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	Crytek Character Animation source code
//	
//	History:
//	28/09/2004 - Created by Ivo Herzeg <ivo@crytek.de>
//
//  Contains:
//  loading of model and animations
/////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _CRY_MODEL_LOADER_HDR_
#define _CRY_MODEL_LOADER_HDR_

#include "ModelAnimationSet.h"

class CCharacterModel;

#include "ParamLoader.h"

class CryCHRLoader
{

public:
	CryCHRLoader()
	{
	}
	~CryCHRLoader() 
	{	
		clear(); 
	}

	CCharacterModel* LoadNewCHR (const string& strGeomFileName, CharacterManager* pManager, uint32 SurpressWarning, uint32 IsSkinAttachment, uint32 nLoadingFlags);
	// cleans up the resources allocated during load
	void clear();

	void LoadParams(CCharacterModel* pModel, const char* paramFileName, uint32 IsSkinAttachment);
	
	// the controller manager for the new model; this remains the same during the whole lifecycle the file without extension
	string m_strGeomFileNameNoExt;

	struct _finddata_t m_fileinfo;

private:
	const string GetDefaultAnimDir();
	void LoadFaceLib( const char* faceLibFile, const char* animDirName, CCharacterModel* pModel );

	//loads animations by using the output of the ParamLoader
	bool LoadAnimations(CParamLoader& paramLoader);
	// load animation files that were parsed from the param file into memory (That are not in DBA)
	uint32 LoadAnimationFiles(CParamLoader& paramLoader, uint32 listID);
	// files that are already in memory can be reused
	uint32 ReuseAnimationFiles(CParamLoader& paramLoader, uint32 listID);


	bool IsModelBiped()
	{
		if (!m_pModel)
			return false;
		return m_pModel->m_ModelSkeleton.GetJointIDByName("Bip01 Pelvis") > 0;
	}
private:
	DynArray<uint32> m_animListIDs;
	CCharacterModel* m_pModel;
};

#endif
